<?php

class Pages extends Controller {

	function __construct()
	{
		parent::Controller();
		$this->load->scaffolding('ox_article');
		$this->load->model('article');	
		//$this->auth->check();
	}
	
	function index()
	{	
		//$adate = date('Y-m-d');
		//die($adate);
		//$this->load->view('welcome_message');
		$data['title'] = 'hello me'; 
		$data['test'] = 'hello';
		$data['body'] = 'Lorem ipsum aute irure doloria deserunt mollit anim id est laborum.11.home test'; 	
		$this->oryx->render('single_page',$data);

	}
	
	function view($path = null)
	{
		
		if ($this->auth->check_password('trytest','_zzD.VGMMCglLKfbjULM')) {
			//$data['body'] = $this->auth->encrypt_password($path);
			$data['body'] = 'yes';
		} else
		{
			$data['body'] = 'no';
		}
	
		$this->oryx->render('single_page',$data);
	}
	
	function test()
	{
		$data['content'] = $this->article->findAll();
		$this->oryx->render('view_articles',$data,'admin');
	}
	
	function add()
	{
		$this->form_validation->set_rules('title', 'Article Title', 'required');
		$this->form_validation->set_rules('content', 'Content', 'required');
		$this->form_validation->set_rules('excerpt', 'Excerpt', 'required');
		$this->form_validation->set_rules('status', 'Status', 'required');

		if ($this->form_validation->run() == FALSE)
		{
			$data['error'] = '';
			$this->oryx->render('add_single_article',$data,'admin');
		}
		else
		{
			$data = $this->_get_form_values();
			
			$data['date_created']= now();

	        $this->article->add($data);
			$data = $this->_clear_form();
			$data['error'] = 'add true';
	        $this->oryx->render('add_single_article',$data,'admin');
		}
	}
	
}